package com.projects.xenia.ref_classes;
import android.database.Cursor;	
import com.projects.xenia.global_modules.MainGlobalModule;

public class EmployeesRefObject {
	
	public EmployeesRefItem RefItem;
	
	public EmployeesRefObject () {
		
		RefItem = new EmployeesRefItem();
		
	}
	
	public EmployeesRefObject (String employee_id) {
		
		RefItem = new EmployeesRefItem();
		if (!GetEmployeeById (employee_id)) {
			RefItem.id = employee_id;
			RefItem.descr = "<object not found>";	
		}
		
	}
	
	public boolean GetEmployeeById (String employee_id) {
			
		boolean _result = false;
			
		Cursor EmployeesCursor = MainGlobalModule.DBE.rawQuery("select id,descr from xref_employees where id = ?", new String [] {employee_id});
		if (EmployeesCursor.getCount()>0) {
			
			EmployeesCursor.moveToFirst();
			
			RefItem.id =  EmployeesCursor.getString(0);
			RefItem.descr =  EmployeesCursor.getString(1); 
			_result = true;
				
		}
		
		EmployeesCursor.close();
			
		return (_result);
			
	}
	
}
